<?php  

defined('C5_EXECUTE') or die(_("Access Denied."));

class ProjectEstatePackage extends Package {

	protected $pkgHandle = 'project_estate';
	protected $appVersionRequired = '5.4.0';
	protected $pkgVersion = '1.0';
	
	function __construct(){
		Loader::library('controller',$this->pkgHandle); //Used by controllers
		Loader::library('dashboardcontroller',$this->pkgHandle); //Used by controllers
	}
	
	public function getPackageDescription() {
		return t('Add multiple project estate to your site.');
	}
	
	public function getPackageName() {
		return t('Project Estate');
	}
	
	public function install() {
		$pkg = parent::install();
		Loader::model('single_page');
		Loader::model('attribute/categories/collection');
		
		// install attributes
		$cab1 = CollectionAttributeKey::add('BOOLEAN',array('akHandle' => 'projectestate_section', 'akName' => t('Project Estate Section'), 'akIsSearchable' => true), $pkg);
		// //  Logo
		$cab1 = CollectionAttributeKey::add('NUMBER',array('akHandle' => 'projectestate_logo', 'akName' => t('Logo'), 'akIsSearchable' => true), $pkg);
		// // Locations
		$cab1 = CollectionAttributeKey::add('SELECT',array('akHandle' => 'projectestate_locations', 'akName' => t('Locations'), 'akIsSearchable' => true), $pkg);
		SelectAttributeTypeOption::add( $cab1, 'Da Nang', 0, 0);
		SelectAttributeTypeOption::add( $cab1, 'Nha Trang', 0, 0);
		SelectAttributeTypeOption::add( $cab1, 'Ho Chi Minh', 0, 0);
		// // Location
		$cab1 = CollectionAttributeKey::add('TEXT',array('akHandle' => 'projectestate_location', 'akName' => t('Location'), 'akIsSearchable' => true), $pkg);
		// // Types
		$cab1 = CollectionAttributeKey::add('SELECT',array('akHandle' => 'projectestate_types', 'akName' => t('Types'), 'akIsSearchable' => true), $pkg);
		SelectAttributeTypeOption::add( $cab1, 'Villa', 0, 0);
		SelectAttributeTypeOption::add( $cab1, 'Condominium', 0, 0);
		SelectAttributeTypeOption::add( $cab1, 'Mixed-use', 0, 0);
		$cab1 = CollectionAttributeKey::add('TEXT',array('akHandle' => 'projectestate_type', 'akName' => t('Type'), 'akIsSearchable' => true), $pkg);
		// // Range Price
		$cab1 = CollectionAttributeKey::add('SELECT',array('akHandle' => 'projectestate_pricerange', 'akName' => t('Price Range'), 'akIsSearchable' => true), $pkg);
		SelectAttributeTypeOption::add( $cab1, '$20.000 - $50.000', 0, 0);
		SelectAttributeTypeOption::add( $cab1, '$50.000 - $100.000', 0, 0);
		// // Price
		$cab1 = CollectionAttributeKey::add('NUMBER', array('akHandle' => 'projectestate_price', 'akName' => t('Price'), 'akIsSearchable' => true), $pkg);
		// // Website
		$cab1 = CollectionAttributeKey::add('TEXT', array('akHandle' => 'projectestate_website', 'akName' => t('Website'), 'akIsSearchable' => true), $pkg);
		// // Number of rooms
		$cab1 = CollectionAttributeKey::add('SELECT',array('akHandle' => 'projectestate_numberofrooms', 'akName' => t('Number of Rooms'), 'akIsSearchable' => true), $pkg);
		SelectAttributeTypeOption::add( $cab1, '1 - 2 bedroom', 0, 0);
		SelectAttributeTypeOption::add( $cab1, '1 - 3 bedroom', 0, 0);
		SelectAttributeTypeOption::add( $cab1, '1 - 4 bedroom', 0, 0);
		SelectAttributeTypeOption::add( $cab1, '1 - 5 bedroom', 0, 0);
		// // Number of room
		$cab1 = CollectionAttributeKey::add('NUMBER',array('akHandle' => 'projectestate_numberofroom', 'akName' => t('Number of Room'), 'akIsSearchable' => true), $pkg);
		
		//install pages
		$def = SinglePage::add('/dashboard/project_estate', $pkg);
		$def->update(array('cName'=>'Project Estate', 'cDescription'=>t('Manage project estate news.')));
		$def = SinglePage::add('/dashboard/project_estate/help', $pkg);
		$def->update(array('cName'=>'Project Estate Help', 'cDescription'=>t('Project Estate help.')));
		
		// install  page types
		Loader::model('collection_types');
		$theme = CollectionType::getByHandle('project');
		if(!$theme || !intval($theme->getCollectionTypeID())){
		     $theme = CollectionType::add(array('ctHandle'=>'project','ctName'=>t('Project Page')),$pkg);
		}
		
		//install block
		BlockType::installBlockTypeFromPackage('projectestate_search', $pkg);
		BlockType::installBlockTypeFromPackage('projectestate_content', $pkg);
	}
}